

# Breyta tolum i romverskar tolur
# M = 1000
# D = 500
# C = 100
# L = 50
# X = 10
# V = 5
# I = 1

annadTup = (1, 5, 10, 50, 100, 500, 1000)
ag = {1: 'I', 5: 'V', 10: 'X', 50: 'L', 100: 'C', 500: 'D', 1000: 'M'}
ga = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
def agiskunaradferd(tup):
	for x in range(len(annadTup)-1):
		if int(tup[1]) in range(annadTup[x], annadTup[x+1]):
			return ((str(tup[0])+str(ag[annadtup[x]])), (int(tup[1])-int(annadTup[x])))

def laga(str):
	for x in range(3, len(str)):
		if str[x-3] == str[x-2] == str[x-1] == str[x]:
			for y in range(len(annadTup)):
				if ga[str[x]] == annadTup[y]:
					bla = str[x] + ag[annadTup[y+1]]
			return str.replace(str[x], bla)

tala = input('Hvada tolu viltu skrifa sem romverska tolu? ')
tups = ("", tala)
z = 0
listiAfTuplum = []
listiAfTuplum.append(tups)
print(listiAfTuplum[0][1])
print(agiskunaradferd(listiAfTuplum[0])[1])

#while 0 != int(listiAfTuplum[z][1]):
#	listiAfTuplum.append(agiskunaradferd(listiAfTuplum[z]))
#	z += 1
#laga(listiAfTuplum[z][0])

